<?php

    class test_uploadAjax_controller extends controllerBase
    {
        public function process()
        {
            if(isset($_FILES['file']))
            {
                // Edit upload location here
                $destination_path = getcwd().DIRECTORY_SEPARATOR;
                for($i = 0; $i < count($_FILES['file']['name']) ; $i++)
                {
                    $file_name = $_FILES['file']['name'][$i];
                    $target_path = $destination_path . basename($file_name);

                    if(@move_uploaded_file($_FILES['file']['tmp_name'][$i], "upload/".$file_name)) {
                        $path = "upload/".$file_name;
                        echo '<script type="text/javascript">alert("OK");</script> ';
                    }
                    else
                    {
                        echo '<script type="text/javascript">alert("Fail");</script> ';
                    }
                }
                die();
            }
        }
    }
?>
